import 'dart:math';

import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: Text("AspectRatio配置说明"),
      ),
      body: HomeScreen(),
    ),
  ));
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Container(
          width: 200,
          child:
              /**
           * 优先让宽充满父容器，然后高度根据aspectRatio进行调整
           */
              AspectRatio(
            aspectRatio: 2.0,
            child: RaisedButton(
              color: Colors.pink,
              child: Text("我是文本"),
              onPressed: () {},
            ),
          ),
        )
      ],
    );
  }
}
